home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
TEMP
/
GNU
/
flex
/
Format
< prev
next >
Wrap
Text File
|
1995-06-28
|
3KB
|
109 lines
Format
Previous: <Examples=>Examples> * Next: <Patterns=>Patterns> * Up: <Top=>!Root>
#Wrap on
{fH3}Format of the input file{f}
The {fCode}flex{f} input file consists of three sections, separated
by a line with just {fEmphasis}%%{f} in it:
#Wrap off
#fCode
definitions
%%
rules
%%
user code
#f
#Wrap on
The {fUnderline}definitions{f} section contains declarations of simple
{fUnderline}name{f} definitions to simplify the scanner specification,
and declarations of {fUnderline}start conditions{f}, which are explained
in a later section.
Name definitions have the form:
#Wrap off
#fCode
name definition
#f
#Wrap on
The "name" is a word beginning with a letter or an
underscore ('\_') followed by zero or more letters, digits, '\_',
or '-' (dash). The definition is taken to begin at the
first non-white-space character following the name and
continuing to the end of the line. The definition can
subsequently be referred to using "\{name\}", which will
expand to "(definition)". For example,
#Wrap off
#fCode
DIGIT [0-9]
ID [a-z][a-z0-9]\*
#f
#Wrap on
defines "DIGIT" to be a regular expression which matches a
single digit, and "ID" to be a regular expression which
matches a letter followed by zero-or-more
letters-or-digits. A subsequent reference to
#Wrap off
#fCode
\{DIGIT\}+"."\{DIGIT\}\*
#f
#Wrap on
is identical to
#Wrap off
#fCode
([0-9])+"."([0-9])\*
#f
#Wrap on
and matches one-or-more digits followed by a '.' followed
by zero-or-more digits.
The {fStrong}rules{f} section of the {fCode}flex{f} input contains a series of
rules of the form:
#Wrap off
#fCode
pattern action
#f
#Wrap on
where the pattern must be unindented and the action must
begin on the same line.
See below for a further description of patterns and
actions.
Finally, the user code section is simply copied to
{fCite}lex.yy.c{f} verbatim. It is used for companion routines
which call or are called by the scanner. The presence of
this section is optional; if it is missing, the second {fEmphasis}%%{f}
in the input file may be skipped, too.
In the definitions and rules sections, any {fEmphasis}indented{f} text or
text enclosed in {fEmphasis}%\{{f} and {fEmphasis}%\}{f} is copied verbatim to the
output (with the {fEmphasis}%\{\}{f}'s removed). The {fEmphasis}%\{\}{f}'s must
appear unindented on lines by themselves.
In the rules section, any indented or %\{\} text appearing
before the first rule may be used to declare variables
which are local to the scanning routine and (after the
declarations) code which is to be executed whenever the
scanning routine is entered. Other indented or %\{\} text
in the rule section is still copied to the output, but its
meaning is not well-defined and it may well cause
compile-time errors (this feature is present for {fCode}POSIX{f} compliance;
see below for other such features).
In the definitions section (but not in the rules section),
an unindented comment (i.e., a line beginning with "\/\*")
is also copied verbatim to the output up to the next "\*\/".